package com.qianfeng.teachdemo.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
import android.widget.RadioGroup;


import com.qianfeng.teachdemo.BaseApplication;
import com.qianfeng.teachdemo.R;
import com.qianfeng.teachdemo.adapter.FragmentTabAdapter;
import com.qianfeng.teachdemo.fragment.CollectFragment;
import com.qianfeng.teachdemo.fragment.DynamicFragment;
import com.qianfeng.teachdemo.fragment.FindFragment;
import com.qianfeng.teachdemo.fragment.HomeFragment;
import com.qianfeng.teachdemo.fragment.MeFragment;
import com.qianfeng.teachdemo.utils.AppManager;

import java.util.ArrayList;

/**
 *
 */
public class Main2Activity extends BaseActivity implements FragmentTabAdapter.OnRgsExtraCheckedChangedListener {
    private RadioGroup radioGroup;
    private FragmentTabAdapter adapter;
    private ArrayList<Fragment> fragments = new ArrayList<Fragment>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();
    }

    private void initView() {
        radioGroup = (RadioGroup) findViewById(R.id.footer_layout);
        fragments.add(new HomeFragment());
        fragments.add(new DynamicFragment());
        fragments.add(new FindFragment());
        fragments.add(new CollectFragment());
        fragments.add(new MeFragment());
        adapter = new FragmentTabAdapter(getSupportFragmentManager(), fragments, R.id.fragment_container, radioGroup);
        adapter.setOnRgsExtraCheckedChangedListener(this);
    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        AppManager.getAppManager().AppExit(BaseApplication.getApplication());
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public void OnRgsExtraCheckedChanged(RadioGroup radioGroup, int checkedId, int index) {


    }

    @Override
    public void onBackPressed() {

    }
}
